import { AliPayRefundData, OptionsType, TokenRequestData } from '@/types/interface'
import {
  BizType,
  OrderStatusCodeType,
  VoltageType,
  ShortTermAdjustType,
  AccountType
} from '@/types/enum'
import { BankCardAccountData } from '@/api/expense/types/expense'
export interface queryOrderDetailInfoRequestData extends TokenRequestData {
  userId: string
  orderId: string
}

/**
 * @interface BizDataType
 * @param orderDetailStatus - 订单状态
 * @param orderDetailStatusDescription - 订单状态描述
 * @param originBikeCode - ??
 * @param orderConfirm - 订单确认时间
 * @param rentUsedCount - 已租赁次数/已租赁时长
 * @param startTime -  订单开始时间
 * @param endTime - 过期时间
 */
export interface BizDataType {
  orderDetailStatus: OrderStatusCodeType
  orderDetailStatusDescription: string
  bikeCode: string
  originBikeCode: string
  batteryId: string
  startTime: string
  rentUsedCount: string
  bikeConfirm: string
  endTime: string
  payStatus: '已支付' | '待支付'
  orderConfirm: string
}
/**
 * @param remainingRefundAmount - 总退款金额
 * @param remainingRefundAmountOverdue - 可退逾期费
 * @param remainingRefundAmountRent - 可退租金
 */
export interface resultDataType {
  remainingRefundAmount: number
  remainingRefundAmountOverdue: number
  remainingRefundAmountRent: number
}
/**
 * @param refundCount -  退款记录条数
 * @param apartTime - TRUE代表在原路退回时限内 不可用其他退款方式
 * @param canRefundDeposit -  可退押金 (带描述)  "0.00元（暂不可退押金）"
 */
export interface orderRefundDataType {
  refundCount: number
  apartTime: boolean
  canRefundDeposit: string
  resultData: resultDataType
}
/**
 * @param RemainingTime - 剩余时长/次数
 * @param giftTime - 赠送时长/次数
 * @param delayDays - 订单已操作延期确认时间 不为0时代表已操作延期
 * @param delayDistanceTime - 操作延期后距离自动确认的时间
 * @param originProductCount - 租赁周期
 * @param createdTime - 支付时间
 * @param cancelable - 是否可取消订单 '1' 可取消
 * @param originRemainingTime - 用于计算退款时长
 */
export interface orderSummaryType {
  RemainingTime: string
  giftTime: string
  delayDays: string
  delayDistanceTime?: string
  originProductCount: string
  createdTime: string
  cancelable: '0' | '1'
  originRemainingTime: string
}
/**
 * @param 套餐名称
 * @param inputVoltage - 电池电压
 * @param deposit - 押金
 * @param imageUrls - 套餐图片
 * @param rentTimeDescription - 租赁周期描述  n天/月/年
 * @param shortName - 租赁周期描述 日/月/年租
 * @param rent - 租金
 */
export interface productSnapshotType {
  name: string
  inputVoltage: VoltageType
  deposit: string
  imageUrls: string
  rentTimeDescription: string
  shortName: string
  rent: string
}
/**
 * @description 原始订单逾期数据
 * @param overdueFlag - 是否逾期 1 逾期 0 未逾期
 * @param overdueAmount - 逾期金额
 * @param overdueTime - 已逾期时长
 * @param paidAmount - 已支付的逾期费用
 */
export interface oldOverdueDataType {
  overdueFlag: '0' | '1'
  overdueAmount: string
  overdueTime: string
  paidAmount: string
  overduePayTime: string
}
/**
 * @description 续租订单逾期数据
 * @param overdueDays - 已支付逾期天数
 * @param totalOverdueAmount - 已支付逾期金额
 */
export interface overdueDataType extends oldOverdueDataType {
  overdueDays: string
  totalOverdueAmount: string
}
/**
 * @description 续租记录
 * @param currentUse - 当前进行中订单 '0' 不是 1是当前进行
 * @param productCount - 租赁周期
 * @param rent - 租金
 * @param createdTime - 支付时间
 */
export interface objectListType {
  orderId: string
  currentUse: '0' | '1'
  productCount: number
  rent: number
  createdTime: string
}
/**
 *
 */
export interface StoreInfoType {
  imageUrls: string
  serviceTime: string
  storeName: string
  contactPerson: string
  contactPhone: string
  address: string
  longtitude: number
  latitude: number
  storeId: number
  merchantId: number
}
/**
 * @description 查询订单详情
 * @param canOverdue - 能否退逾期费 1 | 2 可显示退逾期费 1 禁用退逾期费选项  reason??
 * @param productCount - 租赁数量
 * @param productPrice - 租赁单价
 * @param bizType - 订单所属套餐类型
 * @param productModel - 产品型号
 * @param useTime - 已租赁时长
 * @param finishedTime - 结束时间
 *
 */
export interface queryOrderDetailInfoResponseData {
  canOverdue: number
  productCount: number
  orderId: string
  productPrice: number
  bizType: BizType
  productModel: string
  useTime: string
  finishedTime: string
  storeInfo: StoreInfoType | null
  bizData: BizDataType
  orderRefundData: orderRefundDataType
  orderSummary: orderSummaryType
  productSnapshot: productSnapshotType
  objectList: objectListType[]
  oldOverdueData: oldOverdueDataType | null
  overdueData: overdueDataType | null
}

export type queryOrderDetailInfoResponse = ApiResponseData<queryOrderDetailInfoResponseData>

/** 获取订单套餐调整信息 */

export interface queryStoreOrderDetailInfoRequestData extends TokenRequestData {
  orderId: string
}

/**
 * @param rentTime - 租赁天数
 * @param remainTime - 剩余天数
 * @param overDueTime - 逾期天数
 * @param unpaidTime - 未支付逾期天数
 * @param expirationTime - 初始订单到期时间
 * @param overdue - 逾期0，未逾期1
 * @param isLongTerm - 长租0，次卡1
 * @param giftTime - 赠送时长/次数
 * @param canOverdue - 能否退逾期费 1 | 2 可显示退逾期费 1 禁用退逾期费选项  reason??
 * @param productType -  套餐类型(中文)
 */
export interface queryStoreOrderDetailInfoResponseData {
  orderId: string
  productModel: string
  userPhone: string
  productType: string
  rentTime: string
  remainTime: string
  overDueTime: string
  unpaidTime: string
  expirationTime: string
  overdue: 0 | 1
  isLongTerm: 0 | 1
  giftTime: string
  canOverdue: 0
  remainDeposit: number
  overdueAmount: number
  currentoverdueTime: string
}

export type queryStoreOrderDetailInfoResponse =
  ApiResponseData<queryStoreOrderDetailInfoResponseData>

/**
 * @description 调整订单套餐信息
 * @param type - 0表示增加天数，1减少天数，2减少逾期
 * @param times - 次数
 */
export interface changeOrderDetailInfoRequestData extends TokenRequestData {
  orderId: string
  type: string
  day: number
  hour: number
  minute: number
  times: number
  reason: string
}
export type changeOrderDetailInfoResponse = ApiResponseData<string>

/** 获取短租车订单详情 */
export interface queryShortTermDetailRequestData extends TokenRequestData {
  orderId: string
}
export interface queryShortTermDetailResponseData {
  phone: string //手机号
  orderId: string //订单号
  rideDuration: string //骑行时长
  rent: number //租金
  dispatchFee: number //强制还车费
  repairFee: number
  towingFee: number
  violationFee: number
  deductionAmount: number //抵扣金额
  deductionType: string //抵扣方式
  waitPayAmount: number //剩余待支付
  waitPayRemark: string
  refundRent: number
  refundDispatchFee: number
  refundRepairFee: number
  refundTowingFee: number
  refundViolationFee: number
}

export type queryShortTermDetailResponse = ApiResponseData<queryShortTermDetailResponseData>

/** 调整短租车待付 */

export interface adjustShortTermBikeFeeRequestData extends TokenRequestData {
  orderId: string
  adjustFee: number
  type: ShortTermAdjustType
  reason: string
  userId: string
}

export type adjustShortTermBikeFeeResponse = ApiResponseData<string>

/** 获取订单退款信息 */
export interface queryOrderRefundInfoRequestData extends TokenRequestData {
  phone: string
  userId?: string
  orderId?: string
  type: string
}

export interface OrderInfoType {
  orderId: string
  name: string
}

export interface queryOrderRefundInfoResponseData {
  refundType: OptionsType[]
  batteryOrder?: OrderInfoType[]
  bikeOrder?: OrderInfoType[]
  userId: number
}
export type queryOrderRefundInfoResponse = ApiResponseData<
  queryOrderRefundInfoResponseData & Record<string, any>
>

export type AccountData = AliPayRefundData | BankCardAccountData

/** 取消订单 */
export interface OrderConfirmRequestData extends TokenRequestData {
  userId: string
  orderId: string
}

export type OrderConfirmResponse = ApiResponseData<string>

/** 余额退款申请 */
export interface submitBalanceRefundRequestData extends TokenRequestData {
  userId: string
  orderNo: string
  refundAmount: number
  refundReason: string
  refundPath: AccountType
  contextData?: Record<string, any>
}
export type submitBalanceRefundResponse = ApiResponseData<string>
